package com.myblog.Utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class PathUtils {
    //File的格式为 type/时间/文件名
    public static String setFilePath(String type,String fileName){
        int index = fileName.lastIndexOf(".");
        // test.jpg -> .jpg
        String fileType = fileName.substring(index);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        String datePath = sdf.format(new Date());
        String newFileName= String.valueOf(UUID.randomUUID());
        return datePath + "/" + type + "/" + newFileName + fileType;
    }
}
